package infostroy.bookagolf.common.helpers;

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

/**
 * Created by valer_000 on 2/14/14.
 */
public class ImageHelper {

	private static ImageHelper imageHelper;

	private ImageHelper() {
	}

	public static ImageHelper getInstance() {
		if (imageHelper == null) {
			imageHelper = new ImageHelper();
		}
		return imageHelper;
	}

	public BufferedImage loadImage(String url) {
		BufferedImage image = null;
		try {
			image = ImageIO.read(getClass().getResource(url));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return image;
	}

	public BufferedImage downloadImage(String url) {
		BufferedImage image = null;
		try {
			image = ImageIO.read(new URL(url));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return image;
	}

}
